package com.epoch.base.email;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;

public class MailUtils {
	
	public static String host = "smtp.exmail.qq.com";
	public static String encodeing = "";
	public static String sendEmailAddress = "epochFly官网社区";
	public static String sendName = "epochFly官网社区";
	public static String sendUserName = "epochFly官网社区";
	public static String sendPassword = "epochFly官网社区";
	
	public static void sendMail(String email, String emailMsg) {
		HtmlEmail htmlEmail = new HtmlEmail();
		htmlEmail.setAuthentication(sendUserName, sendPassword);
		try {
			htmlEmail.setCharset("UTF-8");
			htmlEmail.setFrom(sendEmailAddress, sendName);
			htmlEmail.addTo(email);
			htmlEmail.setSubject("epochFly官网社区邮件校验：");
			htmlEmail.setHtmlMsg(emailMsg);
			htmlEmail.send();
		} catch (EmailException e) {
			e.printStackTrace();
		}
	}
	
	private static String getSendHtml() {
		String html = "<!DOCTYPE html>";
	    html += "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
	    html += "<title>Insert title here</title>";
	    html += "</head><body>";
	    html += "<div style=\"width:600px;height:400px;margin:50px auto;\">";
	    html += "<h1>我来看看邮件是否发送成功呢</h1><br/><br/>";
	    html += "<p>下面是通过该协议可以创建一个指向电子邮件地址的超级链接，通过该链接可以在Internet中发送电子邮件</p><br/>";
	    html += "<a href=\"mailto:huntereagle@foxmail.com?subject=test&cc=huntertochen@163.com&body=use mailto sample\">send mail</a>";
	    html += "</div>";
	    html += "</body></html>";
	    return html;
	}
}
